<?php
namespace Home\Controller;
use Think\Controller;

class IndexController extends Controller {
    public function index(){
        $site_img=get_config_value('site_img');
        if(empty($site_img))
        {
            $site_img=__ROOT__.'/Public/Images/background.jpg';
        }
//        $site_img=__ROOT__.'/Public/Images/background.jpg';
        $site_name=get_config_value('site_name');
        $this->assign('site_img',$site_img);
        $this->assign('site_name',$site_name);
        $this->display('login');
    }
    public function login()
    {
        $data['std_id']= I('student_id', '');
        $data['password'] = md5(I('student_password', ''));
        $login_info=M('Login')->where($data)->getField('Id');
        if(!empty($login_info)){
            session('std_id',$data['std_id']);
            $callback = U('home/lesson/index');
            $data = array(
                'info' => 'ok',
                'callback' => $callback
            );
        }else{
            $data = array(
                'info' => '登录失败，请检查登录名和密码是否正确'
            );
        }
        $this->ajaxReturn($data);
    }
}